package com.ecar.core.order.dao;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.ecar.common.dao.mybatis.MybatisMapper;
import com.ecar.common.dto.Pager;
import com.ecar.core.order.entity.Order;

public interface OrderMapper extends MybatisMapper {
	
	/**
	 * 25
	 * @param id
	 * @return
	 */
	List<Order> selectTodayOrder();
	/**
	 * 24
	 * @return
	 */
	List<Order> selectWorkingOrderToday();
	/**
	 * 31
	 * @return
	 */
	List<Order> selectTodayCarpool();
	
    int deleteByPrimaryKey(String id);

    int insert(Order record);

    int insertSelective(Order record);

    Order selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(Order record);
    
    int updateByOrderNumSelective(Order record);
    
    int updateByOrderNum(@Param("orderNum")String orderNum,@Param("endTime")Date endTime,@Param("orderStatus")int orderStatus,@Param("orderPrice")double orderPrice,@Param("payStatus")int payStatus);

    int updateByPrimaryKey(Order record);

	int queryOrderCountByDriverId(String driverId);
	
	int countHalfHourAppointmentOrderByDriverId(@Param("driverId")String driverId,@Param("planTime")Date planTime);

	Double queryTotalPrice(String driverId);
	/**
	 * 订单列表查询
	 * @param driverId
	 * @return
	 */
	List<Order> selectByDriverId(String driverId);
	
	List<Order> selectByDriverIdAndOrderStatus(@Param("driverId")String driverId,@Param("orderStatus")int orderStatus);
	/**
	 * 计算司机总接单数
	 * @param driverId
	 * @return
	 */
	int countByDriverId(String driverId);
	/**
	 * 行程状态接口
	 * @param orderStatus
	 * @param driverId
	 * @return
	 */
	int updateOrderByDriverId(@Param("startTime")Date startTime,@Param("orderStatus")int orderStatus,@Param("orderNum")String orderNum);
	
//	int updateOrderByDriverId1(@Param("orderStatus")int orderStatus,@Param("driverId")String driverId,@Param("orderNum")String orderNum);
	
	int updateOrderByDriverId1(@Param("orderStatus")int orderStatus,@Param("orderNum")String orderNum);
	
	List<Order> getOrderListByQuery(Map<String, Object> param);
    
    List<Order> getAllOrderListByStatus(Map<String, Object> param);
    
    Order selectByOrderNum(String orderNum);
    
    List<Order> selectOrderCountByPassengerId(int passengerId);

	int selectPayOrderCountByPassengerId(int passengerId);
	
	List<Order> selectUnsendOrder();

	/**
	 * @param passengerId
	 * @return
	 */
	List<Order> selectGoingOrderNum(int passengerId);
	
	List<Order> selectAppointmentOrder();
	
	List<Order> selectF2FParentOrder(String driverId);
	
	List<Order> selectAppointmentToNowOrder();
	
	List<Order> selectCarpoolOrderBySeat(int seat);
	
	List<Order> selectCarpoolParentOrder();

	Double queryInvoiceTotalMoney(Integer passengerId);
	/**
	 * 拼车父节点查寻所有拼车单
	 * @param orderNum
	 * @return
	 */
	List<Order> selectOrderByParentOrder(String orderNum);
	
	/**
	 * 获取超时订单
	 * @return
	 */
	List<Order> overTimeOrder();
	/**
	 * 获取5分钟内的预约拼车单
	 * @return
	 */
	List<Order> selectAppointmentCarpool();
	
	int queryDriverOrderNumber(String driverId);
	
	int countUnendOrderByDriverId(String driverId);

	Integer queryOrderStatus(String orderNo);
	
	List<HashMap<String, Object>> selectByPager(Pager pager);
}